﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//for editor
using System.Drawing.Design;
using System.Windows.Forms.Design;

namespace WodLib.Controls
{
    internal class MoralityEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (!(value is HumanMorality))
                return value;

            IWindowsFormsEditorService service = (IWindowsFormsEditorService)
                provider.GetService(typeof(IWindowsFormsEditorService));

            if (service != null)
            {
                //WodCollectionEditorForm<T> editor =
                //    new WodCollectionEditorForm<T>((List<T>)value);
                //service.ShowDialog(editor);
                MoralityEditorForm editor = 
                    new MoralityEditorForm((HumanMorality)value);
                service.ShowDialog(editor);
            }

            return value;
        }
    }

}
